import request from "@/api/request"

//首页二级分类列表
export async function indexList() {
    const res = await request({
        url: '/shop/category/list',
        method: 'get'
    })
    //注意：最后需要把res返回，前台执行方法时才能取到res!!!
    return res
}

//首页顶部推荐商品
export async function indexTop() {
    const res = await request({
        url: '/shop/category/top',
        method: 'get'
    })
    return res
}

//首页二级分类跳转商品页
export async function getByCategoryId(categoryId) {
    console.log(categoryId);
    const res = await request({
        url: '/shop/product/list',
        method: 'get',
        params: {
            categoryId
        }
    })
    return res
}

//商品详情
export async function getByProductId(productId) {
    console.log(productId);
    const res = await request({
        url: '/shop/product/item',
        method: "get",
        params: {
            productId
        }
    })
    return res
}